var XYCZ = {
	amountDom:'main1',
	areaDom:'main2',
	peoperDom:'main3',
	dareaDom:'main4',
	renderBar:function(data){
	     var option = ECharts.ChartOptionTemplates.Bars(data,'各区域场站数量对比');  
	     var container = $("#"+this.amountDom)[0];  
	     opt = ECharts.ChartConfig(container, option);  
	     ECharts.Charts.RenderChart(opt); 
	},
	renderPie:function(data){
		    var option = ECharts.ChartOptionTemplates.Pie(data,"各区域场站面积对比");
		    var container = $("#"+this.areaDom)[0];
		    opt = ECharts.ChartConfig(container, option);
		    ECharts.Charts.RenderChart(opt);
	},
	renderPeoper:function(data){
	    var option = ECharts.ChartOptionTemplates.Bars(data,"各区划场站数量/人口比值");
	    var container = $("#"+this.peoperDom)[0];
	    opt = ECharts.ChartConfig(container, option);
	    ECharts.Charts.RenderChart(opt);
	},
	renderArea:function(data){
	    var option = ECharts.ChartOptionTemplates.Pie(data,"各区划场站面积/占地面积比值");
	    var container = $("#"+this.dareaDom)[0];
	    opt = ECharts.ChartConfig(container, option);
	    ECharts.Charts.RenderChart(opt);
	},
	init:function(){
		//数量
		var data = [{ name: '', value:0, group: '' }];  
		this.renderBar(data);
		//面积
		var data = [{ name: '', value:100}];
		this.renderPie(data);
		//人口
		var data = [{name:'', value:0, group: '数量/人口（万）' }];  
		this.renderPeoper(data);
		//占地面积
		var data = [{ name: '', value:0}]; 
		this.renderArea(data);
	},
	tjAmount:function(){
		var thiz = this;
		var shulingChart = require('echarts').init($("#"+this.amountDom)[0]);
		shulingChart.showLoading({  
	         text : "场站数量正在努力统计中..."  
	     });
		 $.ajax({  
		        type : "post",  
		        async : false, //同步执行  
		        url : appConfig.contPath+"/tl/tj!getDistrictsAmount.action",  
		        data : $("#seachform").serialize(),  
		        dataType : "json", //返回数据形式为json  
		        success : function(result) {  
		            if (result.success) { 
		            	thiz.renderBar(result.data.number);
		            	thiz.renderPeoper(result.data.bizhi);
		            }  
		        },  
		        error : function(errorMsg) {  
		        	$.jBox.error('抱歉，图表请求数据失败啦!', '提醒');
		        }  
		    });
	},
	tjArea:function(){
		var thiz = this;
		var areaChart = require('echarts').init($("#"+this.areaDom)[0]);
		areaChart.showLoading({  
	        text : "场站面积正在拼命计算中..."  
	    });
		  $.ajax({  
		        type : "post",  
		        async : false, //同步执行  
		        url : appConfig.contPath+"/tl/tj!getDistrictsArea.action",  
		        data : $("#seachform").serialize(),
		        dataType : "json", //返回数据形式为json  
		        success : function(result) {  
		            if (result.success) { 
		            	thiz.renderPie(result.data.number);
		            	thiz.renderArea(result.data.bizhi);
		            } 
		        },  
		        error : function(errorMsg) {  
		            alert("图表请求数据失败啦!");  
		        }  
		    });
	}
}
//查询
function tjXycz(){
	XYCZ.tjAmount(); 
	XYCZ.tjArea(); 
}
//初始化
$(function () {
	XYCZ.init();
});